<!DOCTYPE html>
<html>
	<head>
	<title>预算</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">

		<%include("/common/include.html"){}%>
		<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<style>
			.refund ul li{
				display:inline-block;
				height:50px;
				width:200px;
				line-height:50px;
				position:relative;
			}
			.refund ul li div{
				position:absolute;
				right:0px;
			}
		</style>
	<body>
		<div class="easyui-layout" data-options="fit:true" style="width:100%;height:100%;">		
			<div data-options="region:'center'"  style="overflow-x:hidden;">
				<div class="refund" >
					<ul>
						<li>
							<div>
								<input id="budgetYearIds" type="hidden" value="${budget.ids !}">
								<input id="organIds" type="hidden" value="${organ.ids !}">
								<input id="lcIds" type="hidden" value="${lcIds !}">
								<span>开业时间：</span>
								<input class="easyui-textbox theme-textbox-radius" style="width: 100px;height: 32px;" readonly="readonly" value="${organ.addTime !}"/>					
							</div>
						</li>
						<li>
							<div>
								<span id="old"></span>
								<input id="oldNum" class="easyui-numberbox theme-textbox-radius" style="width: 100px;height: 32px;" value="${budget.lastYearNum !}"/>
							</div>
						</li>
						<li>
							<div>
								<span id="now"></span>
								<input id="nowNum" class="easyui-numberbox theme-textbox-radius" style="width: 100px;height: 32px;" value="${budget.nowYearNum !}"/>
							</div>						
						</li>
						<li>
							<div>
								<span id="next"></span>
								<input id="nextNum" class="easyui-numberbox theme-textbox-radius" style="width: 100px;height: 32px;" value="${budget.nextYearNum !}"/>
							</div>
						</li>
					</ul>
				</div>
				<table id="dudgetYear-datagrid" class="easyui-datagrid"  style="width:100%;height:89%">
				</table>
				<div id="tb" style="height: auto">
					
					<div style="margin-top: 3px;">
						年度预算   <a href="#" onclick='customerInfo_xls()' class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:67px;margin-left: 30px;">导出</a>
					</div>
				</div>
			</div>
		</div>
<!-- 		<script src="${cxt !}/sb/js/budgetYear/budgetYear.js" type="text/javascript" charset="utf-8"></script> -->
		<script type="text/javascript">
		var date=new Date;
		var year=date.getFullYear(); 
		var ids=$('#budgetYearIds').val();
		var organIds=$('#organIds').val();
		$(document).ready(function() {
			 $('#old').text((year-1)+"营业时间："); $('#now').text(year+"营业时间："); $('#next').text((year+1)+"营业时间：");
			loadBudgetYearTable();
		});
		function  loadBudgetYearTable()
		{	
			
			var columns=[[
			              {field:'proids',title:'产品ids',hidden:'true'},
			              {field:'proname',title:'产品名称',width:100,align:'center'},
			              {field:'oldyearpurchased',title:(year-1)+'年全年进货量',width:120,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return 0;}
			            	  }
			              },
			              {field:'oldmonthpurchased',title:(year-1)+'年月平均进货量',width:130,align:'center',
			            	  formatter: function(value,row,index)
			            	  {		
			            		  var oldtime=$('#oldNum').numberbox('getValue'); 
			            		  if(oldtime==0)
			            		  {
			            			  return 0;
			            		  }
			            		  if(row.oldyearpurchased!=null){
			            			  var a=row.oldyearpurchased/oldtime;
			            			  return  a.toFixed(2);}
			            		  else{ return 0;}
			            	  }
			              },
			              {field:'now9purchased',title:year+'年1-9月进货量',width:120,align:'center',
			            	  formatter: function(value,row,index)
			            	  {		
			            		  if(value!=null){return  value;}
			            		  else{ return row.now9purchased='0';}
			            	  }
			              },
			              {field:'now10willpurchased',title:year+'年10月预计进货量',width:150,align:'center',
			            	  formatter: function(value,row,index)
			            	  {		
			            		  if(value!=null){return  value;}
			            		  else{ return row.now10willpurchased='0';}
			            	  }
			              },
			              {field:'now11willpurchased',title:year+'年11月预计进货量',width:150,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.now11willpurchased='0';}
			            	  }
			              },
			              {field:'now12willpurchased',title:year+'年12月预计进货量',width:150,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.now12willpurchased='0';}
			            	  }
			              },
			              {field:'nowyearwillpurchased',title:year+'年全年预计进货量',width:140,align:'center',
			            	  formatter: function(value,row,index)
			            	  {	
			            		 var a =parseFloat(row.now9purchased)+parseFloat(row.now10willpurchased)+parseFloat(row.now11willpurchased)+parseFloat(row.now12willpurchased);
			            		 return row.nowyearwillpurchased=a;
			            	  }
			              },
			              {field:'nowmonthwillpurchased',title:year+'年月平均预计进货量',width:150,align:'center',
			            	  formatter: function(value,row,index)
			            	  {		
			            		  var nowtime=$('#nowNum').numberbox('getValue');
			            		  if(nowtime==0)
			            		  {
			            			  return 0;
			            		  }
			            		  var a=parseFloat(row.nowyearwillpurchased)/nowtime;
			            		 return row.nowmonthwillpurchased=a.toFixed(2);
			            	  }
			              },
			              
			              {field:'januarynum',title:(year+1)+'年1月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.february='0';}
			            	  }
			              },
			              {field:'februarynum',title:(year+1)+'年2月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.february='0';}
			            	  }
			              },
			              {field:'marchnum',title:(year+1)+'年3月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.march='0';}
			            	  }
			              },
			              {field:'aprilnum',title:(year+1)+'年4月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.april='0';}
			            	  }
			              },
			              {field:'maynum',title:(year+1)+'年5月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.may='0';}
			            	  }
			              },
			              {field:'junenum',title:(year+1)+'年6月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.june='0';}
			            	  }
			              },
			              {field:'julynum',title:(year+1)+'年7月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.july='0';}
			            	  }
			              },
			              {field:'augustnum',title:(year+1)+'年8月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.august='0';}
			            	  }
			              },
			              {field:'septembernum',title:(year+1)+'年9月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.september='0';}
			            	  }
			              },
			              {field:'octobernum',title:(year+1)+'年10月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.october='0';}
			            	  }
			              },
			              {field:'novembernum',title:(year+1)+'年11月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.november='0';}
			            	  }
			              },
			              {field:'decembernum',title:(year+1)+'年12月',width:70,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.december='0';}
			            	  }
			              },
			              {field:'yearsum',title:(year+1)+'年全年预计进货量',width:150,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.december='0';}
			            	  }
			              },
			              {field:'monthnum',title:(year+1)+'年月平均预计进货量',width:150,align:'center',
			            	  formatter: function(value,row,index)
			            	  {
			            		  if(value!=null){return  value;}
			            		  else{ return row.december='0';}
			            	  }
			              }
			              ]];
			
			
			
			
			
			
			$('#dudgetYear-datagrid').datagrid({
				cls: "theme-datagrid",
				  singleSelect:true,  
				  rownumbers: true,
				  toolbar: '#tb',
				  columns:columns,
				  url: "ShowBudgetYear",
				  queryParams:{"ids":ids,"organIds":organIds,"now":year}
			});
		}
		
		function  customerInfo_xls()
		{
			var oldNum=$('#oldNum').val();
			var nowNum=$('#nowNum').val();
			var nextNum=$('#nextNum').val();
			
			var url = "${cxt!}/budgetYearStatistic/excel?ids=" + ids + "&organIds=" + organIds+"&now="+year+
					"&oldNum="+oldNum+"&nowNum="+nowNum+"&nextNum="+nextNum;
			window.location.href = url;
		}
		</script>
	</body>
</html>
